/**
 * 
 */
package team.helpmephone.app.main;

import team.helpmephone.app.common.HelpMePhoneAction;
import team.helpmephone.app.time.ReceiverTimeCheck;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.util.Log;

/**
 * Class : ReceiverHelpMePhone.java<br>
 * Description: Help Me, Phone Main BroadcastReceiver.<br>
 * Copyright: Team HelpMe, Phone<br>
 * 
 * @author Jonghwa, Lee
 * @milestone 0.1
 * @created 2010. 3. 22.
 * @modified .
 * @sw_block Main
 */
public class ReceiverHelpMePhone extends BroadcastReceiver {

	private static final String TAG = "MAIN RECEIVER";

	private BroadcastReceiver timeTickReceiver = new ReceiverTimeCheck();
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see android.content.BroadcastReceiver#onReceive(android.content.Context, android.content.Intent)
	 */
	@Override
	public void onReceive(Context context, Intent intent) {
		Log.v(TAG, "ACTION = " + intent.getAction() + ", TYPE = " + intent.getType() + ", CATEGORIES = " + intent.getCategories());
		String action = intent.getAction();
		if (Intent.ACTION_BOOT_COMPLETED.equals(action)) {
			context.getApplicationContext().registerReceiver(timeTickReceiver, new IntentFilter(Intent.ACTION_TIME_TICK));
		} else if (Intent.ACTION_BATTERY_LOW.equals(action)) {
			// TODO : ACTION_BATTERY_LOW
		} else if (Intent.ACTION_SHUTDOWN.equals(action)) {
			// TODO : ACTION_SHUTDOWN
		} else if (Intent.ACTION_TIME_CHANGED.equals(action)) {
			// TODO : ACTION_TIME_CHANGED
		} else if (Intent.ACTION_TIMEZONE_CHANGED.equals(action)) {
			// TODO : ACTION_TIMEZONE_CHANGED
		} else if (Intent.ACTION_PACKAGE_RESTARTED.equals(action)) {
			// TODO : ACTION_PACKAGE_RESTARTED
		} else if (HelpMePhoneAction.ACTION_ACTIVE_CURRENT_STATE.equals(action)) {
			context.getApplicationContext().registerReceiver(timeTickReceiver, new IntentFilter(Intent.ACTION_TIME_TICK));
		}
	}
}
